package org.neuedu.chapter06_0622.demo04;

import java.util.Arrays;

public class Test1 {
    public static void main(String[] args) {
        Emp emp1 = new Emp();
        emp1.setEmpno(7369);
        emp1.setEname("SMITH");
        emp1.setSal(999);

        Emp emp2 = new Emp();
        emp2.setEmpno(7368);
        emp2.setEname("TOM");
        emp2.setSal(1234);

        Emp emp3 = new Emp();
        emp3.setEmpno(6899);
        emp3.setEname("LUCY");
        emp3.setSal(899);

        Emp emp4 = new Emp();
        emp4.setEmpno(9527);
        emp4.setEname("HuaAn");
        emp4.setSal(3278);

        Emp[] emps = {emp1, emp2, emp3, emp4};
        for (int i = 0; i < emps.length - 1; i++) {
            for (int j = i + 1; j < emps.length; j++) {
                if (emps[i].getSal() < emps[j].getSal()) {
                    Emp temp = emps[i];
                    emps[i] = emps[j];
                    emps[j] = temp;
                }
            }
        }

        System.out.println(Arrays.toString(emps));
    }
}